home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / E / Demos / IntMandel.e next >
Encoding:
Text File  |  1997-05-03  |  1.5 KB  |  62 lines

  1. -> This is a Mandel generator from the Amiga E archive (which was converted
  2. -> from Oberon) and is now converted to work with GMS.
  3.  
  4. MODULE 'games','games/games'
  5.  
  6. CONST ITERDEPTH=50 ->This constant defines the detail of the mandel.
  7.  
  8. PROC main()
  9.  DEF screen:PTR TO gamescreen,zr,zi,ar,ai,dr,di,sr,si,st,x,y,i
  10.  
  11.  IF gmsbase := OpenLibrary('GMS:GPI/Master.GPI',0)
  12.   SetUserPrefs('Mandel Generator v1.0')
  13.   IF (screen := AddScreen([TAGS,0,
  14.      GSA_SCRWIDTH,640,
  15.      GSA_SCRHEIGHT,512,
  16.      GSA_AMTCOLOURS,16,
  17.      GSA_SCRMODE,HIRES OR LACED,
  18.      TAGEND]))
  19.  
  20.    x:=256/screen.amtcolours*2
  21.    FOR i:=0 TO screen.amtcolours-1 DO UpdateColour(screen,i,(Shl(i*x,8) OR (i*x)))
  22.  
  23.    sr := $400000/screen.scrwidth  -> shrink horiz
  24.    si := $300000/screen.scrheight -> shrink vert
  25.    st := $140000*-2               -> move side
  26.    zi := $160000                  -> move up
  27.  
  28.    ShowScreen(screen)
  29.    InitJoyPorts()
  30.  
  31.    FOR y:=screen.scrheight-1 TO 0 STEP -1
  32.     IF (ReadMouse(JPORT1) AND MB_LMB) THEN JUMP end
  33.     zi := zi-si
  34.     zr := st
  35.     FOR x:=0 TO screen.scrwidth-1
  36.       i := 0
  37.       ar := zr
  38.       ai := zi
  39.       REPEAT
  40.         dr := Shr(ar,10)
  41.         di := Shr(ai,10)
  42.         ai := dr*2*di+zi
  43.         dr := dr*dr
  44.         di := di*di
  45.         ar := dr-di+zr
  46.         i++
  47.       UNTIL (i>ITERDEPTH) OR (dr+di>$400000)
  48.       DrawPixel(screen,BUFFER1,x,y,Mod(i,screen.amtcolours))
  49.       zr:=zr+sr
  50.     ENDFOR
  51.    AutoSwitch()
  52.    ENDFOR
  53.    WaitLMB()
  54.  
  55. end:
  56.   DeleteScreen(screen)        
  57.   ENDIF
  58.  CloseGMS()
  59.  ENDIF
  60. ENDPROC
  61.  
  62.